﻿using Microsoft.AspNetCore.Mvc;
using Qy.Scenario;
using System.Threading.Tasks;

namespace Qy.Web.Areas.Home.Controllers;

[Area("Home")]
public class OldCmsController : Base
{
    private readonly ContentOldCmsService _contentService;

    public OldCmsController(ContentOldCmsService contentService)
    {
        _contentService = contentService;
    }

    [HttpGet]
    public async Task<IActionResult> IndexAsync([FromQuery] ContentOldCmsQuery query)
    {
        PagedInfo<ContentOldCms> infoList = await _contentService.PageList(query);
        ViewBag.keyword = query?.Title;
        return View(infoList);
    }

    [HttpGet]
    public async Task<IActionResult> InfoAsync(int id = 0)
    {
        if (id < 1) return View("../Common/404");
        ViewContentOldCms article = await _contentService.GetOneAsync(id);
        if (article == null) return NotFound();
        return View("Info", article);
    }
}
